//
//  WelcomePagesHelp.m
//  AdverticeTest
//
//  Created by tc on 2018/6/29.
//  Copyright © 2018年 tc. All rights reserved.
//

#define kScreenWidth [UIScreen mainScreen].bounds.size.width
#define kScreenHeight [UIScreen mainScreen].bounds.size.height


#import "WelcomePagesHelp.h"
#import "WelcomePagesView.h"

@interface WelcomePagesHelp ()

@property (weak, nonatomic) UIWindow *curWindow;

@property (strong, nonatomic) WelcomePagesView *curIntroductoryPagesView;

@end

@implementation WelcomePagesHelp


static WelcomePagesHelp *shareInstance_ = nil;
+ (instancetype)shareInstance
{
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        shareInstance_ = [[WelcomePagesHelp alloc] init];
    });
    
    return shareInstance_;
}

+ (void)showIntroductoryPageView:(NSArray<NSString *> *)imageArray
{
    if (![WelcomePagesHelp shareInstance].curIntroductoryPagesView) {
        [WelcomePagesHelp shareInstance].curIntroductoryPagesView = [WelcomePagesView pagesViewWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight) images:imageArray];
    }
    
    [WelcomePagesHelp shareInstance].curWindow = [self mainWindow];
    [[WelcomePagesHelp shareInstance].curWindow addSubview:[WelcomePagesHelp shareInstance].curIntroductoryPagesView];
}

+ (UIWindow *)mainWindow
{
    UIApplication *app = [UIApplication sharedApplication];
    if ([app.delegate respondsToSelector:@selector(window)]){
        
        return [app.delegate window];
    }
    else{
        return [app keyWindow];
    }
}



@end
